#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QFileDialog>
#include <QFileInfoList>
#include <QMessageBox>
#include <QTreeWidgetItem>
#include <QMediaPlayer>
#include <QAudioOutput>
#include <QPixmap>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void showPathInfo(QString);

private slots:
    void on_openFileButton_clicked();
    void on_playButton_clicked();
    void onItemDoubleClicked(QTreeWidgetItem*);
    void updatePlayButton(bool playing);

    void on_LastButton_clicked();

    void on_PassButton_clicked();

private:
    Ui::MainWindow *ui;

    QMediaPlayer* player;
    QAudioOutput* audioOutput;
    QFileInfoList musicList;
    QTimer* updateTimer;
    QPixmap* volumePic;

    void initButton();
    void initTree();
    void initPlayer();
    void initSlider();
    void initLabel();

    void updateTree(const QFileInfoList&);
    void updateMusicSlider();

    void playMusic();
    void handlePlayingStatusChanged(QMediaPlayer::MediaStatus);
};
#endif // MAINWINDOW_H
